import { Button } from "@/components/button";
import { useTransition } from "react";

const StartTransition: React.FC = () => {
  const [isPending, startTransition] = useTransition();

  const handleSubmit = () => {
    startTransition(async () => {
      await new Promise((resolve) => setTimeout(resolve, 1000));
    });
  };

  return (
    <>
      <div className="text-xl mb-4">React: startTransition</div>
      <Button onClick={handleSubmit}>加载</Button>
      {isPending ? "loading..." : "submit"}
    </>
  );
};

export default StartTransition;
